package com.xianyu.open.restclient.constants;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 *
 * @author bailinan
 * @date 2018/7/22
 */
public class RestClientApplicationContextUtils implements ApplicationContextAware{
    private static ApplicationContext applicationContext;

    public static ApplicationContext getApplicationContext() {
        return applicationContext;
    }

    public static <T> T getBean(Class<T> beanClass){
        return applicationContext.getBean(beanClass);
    }


    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        RestClientApplicationContextUtils.applicationContext = applicationContext;
    }
}
